#!/bin/sh
# Arguments:
#  $1 = host_name (Short name of host that the service is
#       associated with)
#  $2 = state_string (A string representing the status of
#the given service - "OK", "DOWN", "UNREACHABLE"
# or"UNKNOWN")
#  $3 = plugin_output (A text string that should be used
#       as the plugin output for the service checks)
## Convert the state string to the corresponding return code

return_code=2
case "$2" in
        UP)
                return_code=0
                ;;
        DOWN)
                    return_code=1
                ;;
        UNREACHABLE)
                    return_code=2
                ;;
esac

# pipe the service check info into the send_nsca program, which
# in turn transmits the data to the nsca daemon on the central
# monitoring server

/usr/bin/printf "%s\t%s\t%s\n" "$1" "$return_code" "$3" |/usr/sbin/send_nsca 192.168.1.8 -p 5667 -c /etc/nagios/send_nsca.cfg

